package com.im.services.controller;

import com.im.services.utils.ChatGptUtils;
import com.im.services.utils.HttpClientUtils;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * User: key
 * ClassName:ChatController
 * Date: 2023/7/13
 * Time: 16:38
 * description:
 */
@RestController
public class ChatController {

    @Value("${chatgpt.apiUrl}")
    private String apiUrl;

    @Value("${chatgpt.apiKey}")
    private String apiKey;

    @Value("${chatgpt.maxToken}")
    private String maxToken;

    @Value("${chatgpt.model}")
    private String model;


    @PostMapping("/send")
    public String send(){
        ChatGptUtils chatGptUtils = new ChatGptUtils();
        Map<String,String> param = new HashMap<>();
        param.put("apiKey",apiKey);
        param.put("apiUrl",apiUrl);
        param.put("maxToken",maxToken);
        param.put("model",model);
        param.put("content","你好呀");
        String s = chatGptUtils.request(param);
        return s;
    }




}
